<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象的遍历</title>
</head>
<body>
    <script>
        let gu={
            age:20,
            sex:'male',
        }
        gu[Symbol.iterator]=function(){
            let index=0;
            return{
                next(){
                    index++;
                    if(index===1){
                        return{
                            value:gu.age,
                            done:false
                        };
                    }else if(index===2){
                        return{
                            value:gu.sex,
                            done:false
                        };
                    }else{
                        return{
                            done:true
                        };
                    }
                }
            }
        }
        for(var y of gu){
            console.log(y)
        }
var x=gu[Symbol.iterator]();
x.next();
console.log(x)
x.next();
    </script>
</body>
</html>